package vmcs.boundary.listener;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * Title:        VMCS
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:      ISS
 * @author Pang Pingli
 * @version 1.0
 */

 import java.awt.*;
import vmcs.boundary.MessageDialog;
import vmcs.controller.StoreController;

public class StoreViewerListener implements ActionListener {

  private char             type;
  private int              item;
  private StoreController  storeCtrl;

  public StoreViewerListener(char type, int item, StoreController sctrl) {
    this.type = type;
    this.item = item;
    storeCtrl = sctrl;

  }
  public void actionPerformed(ActionEvent e) {
    /**@todo: Implement this java.awt.event.ActionListener method*/
    TextField  vf;
    int        qty;
    String     sqty;

    vf = (TextField) e.getSource();

    sqty = vf.getText();
    try {
      qty = Integer.parseInt(sqty);
    } catch (NumberFormatException ee){
      MessageDialog ms = new MessageDialog(storeCtrl.getMachinerySimulatorPanel(), MessageDialog.NUMBER_FORMAT_ERROR);
      return;
    }

    storeCtrl.changeStoreQty(type, item, qty);
  }
}